package com.cxhc.app.api;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

import com.cxhc.common.utils.poi.ExcelUtil;
import com.cxhc.system.domain.app.CmRoomInfo;
import com.cxhc.system.service.app.ICmRoomInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cxhc.common.core.controller.BaseController;
import com.cxhc.common.core.domain.AjaxResult;
import com.cxhc.common.core.page.TableDataInfo;

/**
 * 房间信息Controller
 * 
 * @author Dhq
 * @date 2024-11-14
 */
@RestController
@RequestMapping("/api/room")
public class CmRoomInfoController extends BaseController
{
    @Autowired
    private ICmRoomInfoService cmRoomInfoService;

    /**
     * 查询房间信息列表
     */
    @PostMapping("/list")
    public Map<String, List<CmRoomInfo>> list(@RequestBody CmRoomInfo cmRoomInfo)
    {
        startPage();
        return  cmRoomInfoService.selectCmRoomInfoList(cmRoomInfo);
    }

    /**
     * 获取房间信息详细信息
     */
    @GetMapping(value = "/detail/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(cmRoomInfoService.selectCmRoomInfoById(id));
    }

    /**
     * 新增房间信息
     */
    @PostMapping("/insert")
    public AjaxResult add(@RequestBody CmRoomInfo cmRoomInfo)
    {
        return toAjax(cmRoomInfoService.insertCmRoomInfo(cmRoomInfo));
    }

    /**
     * 修改房间信息
     */
    @PostMapping("/update")
    public AjaxResult edit(@RequestBody CmRoomInfo cmRoomInfo)
    {
        return toAjax(cmRoomInfoService.updateCmRoomInfo(cmRoomInfo));
    }

    /**
     * 删除房间信息
     */
    @GetMapping(value = "/delete/{id}")
    public AjaxResult remove(@PathVariable Long id)
    {
        return toAjax(cmRoomInfoService.deleteCmRoomInfoById(id));
    }
}
